package nothing;

import java.sql.Date;
import java.util.ArrayList;
import java.util.List;
import org.apache.log4j.Logger;

public class Util{
    static Logger log = Logger.getLogger(Util.class);
    
     private Util() {
    }

    public static String getDateDisplay(Date date){
        if (date == null){
            date = new Date(new java.util.Date().getTime());
        }
        java.text.SimpleDateFormat formatter 
        = new java.text.SimpleDateFormat("dd/MM/yyyy HH:mm:ss");
        return formatter.format(date);
    }
     
     public static Date getDate(String date){
        java.text.SimpleDateFormat formatter //                    20010705102827 my sqlformat
        = new java.text.SimpleDateFormat("yyyyMMddHHmmss");
        return new Date(formatter.parse(date,new java.text.ParsePosition(0)).getTime());
    }

    public static Object[] listToArray(List<Object[]> list, int index){
        Object[] object = new Object[list.size()];
        int i=0;
        while (i<list.size()){
            Object[] results = (Object[]) (list.get(i));
            object[i] = results[index];
            i++;
        }
        return object;        
    }

    public static List toList(List<Object[]> list, int index){
        final List object = new ArrayList(list.size());
        int i=0;
        while (i<list.size()){
            final Object[] results = (Object[]) (list.get(i));
            object.add(results[index]);            
            i++;
        }
        return object;        
    }
    
}
